/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package vue;

import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JComboBox;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;


/**
 *
 * @author Simon
 */
public class ComboBoxSites extends JComboBox {

    public ComboBoxSites() throws Exception{
        
        SAXBuilder sxb = new SAXBuilder();

        try {
            Document document = sxb.build(new File("fichiers/sessions.xml"));
            Element racine = document.getRootElement();

            List<Element> listeSessions = racine.getChildren("site");
            for (Element site : listeSessions) {
                this.addItem(site.getAttributeValue("nom"));
            }
        } catch (JDOMException | IOException e) {
            throw new Exception(e.getMessage());
        }
    }
}
